home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / lome / part04 < prev    next >
Encoding:
Internet Message Format  |  1991-01-08  |  52.3 KB

  1. Path: j.cc.purdue.edu!mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!wuarchive!uunet!papaya.bbn.com!rsalz
  2. From: rsalz@bbn.com (Rich Salz)
  3. Newsgroups: comp.sources.unix
  4. Subject: v23i054:  Line oriented macro processor, Part04/09
  5. Message-ID: <3029@litchi.bbn.com>
  6. Date: 29 Nov 90 17:42:34 GMT
  7. Organization: BBN Systems and Technologies, Cambridge MA
  8. Lines: 2011
  9. Approved: rsalz@uunet.UU.NET
  10.  
  11. Submitted-by: Darren New <new@ee.udel.edu>
  12. Posting-number: Volume 23, Issue 54
  13. Archive-name: lome/part04
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 4 (of 9)."
  22. # Contents:  LOME/LOME.h LOME/LOME.mac LOME/LOME1.out LOME/LOME5.c
  23. #   LOME/SCMdebug.mac PPL/PPLUnix.c TFS/TFS.h
  24. # Wrapped by new@estelle.ee.udel.edu on Tue Aug 14 16:09:58 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'LOME/LOME.h' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'LOME/LOME.h'\"
  28. else
  29. echo shar: Extracting \"'LOME/LOME.h'\" \(6152 characters\)
  30. sed "s/^X//" >'LOME/LOME.h' <<'END_OF_FILE'
  31. X/*
  32. X * LOME.h
  33. X * Line Oriented Macro Expander Header file
  34. X * Copyright 1989 Darren New
  35. X *
  36. X */
  37. X
  38. X#include "PPL.h"
  39. X#include "MacroIO.h"
  40. X
  41. X/* ADJUSTABLE PARAMETERS: */
  42. X
  43. X#define MAXmacrochars 15000 /* max # of macro header or body characters */
  44. X#define MAXvarnames   500   /* max # of variables allowed */
  45. X#define MAXnests      200   /* max # of nested macro expansions */
  46. X#define MAXustack     50    /* max # items on user stack */
  47. X#define MAXstreams    20    /* max # items on input stream stack */
  48. X
  49. Xtypedef int moffs; /* type of in which will hold -1..MAXmacrochars */
  50. X
  51. X/* NON-ADJUSTABLE DECLARATIONS: */
  52. X
  53. X#define O_ESC  0        /* escape */
  54. X#define O_PHC  1        /* placeholder character */
  55. X#define O_HEOL 2        /* header end-of-line */
  56. X#define O_SUBS 3        /* substitution */
  57. X#define O_BEOL 4        /* body end-of-line */
  58. X#define O_ZERO 5        /* digit zero */
  59. X#define O_UCA  6        /* first upper-case letter */
  60. X#define O_LCA  7        /* first lower-case letter */
  61. X#define O_UCZ  8        /* last upper-case letter */
  62. X#define O_FILEOP 9        /* file operation character */
  63. X#define O_CTRLOP 10        /* control operation character */
  64. X#define O_OQ     11        /* open quote */
  65. X#define O_CQ     12        /* close quote */
  66. X#define O_OP     13        /* open paren */
  67. X#define O_CP     14        /* close paren */
  68. X#define O_PLUS     15        /* plus sign */
  69. X#define O_MINUS  16        /* minus sign */
  70. X#define O_MULT     17        /* multiplication sign */
  71. X#define O_DIV     18        /* division sign */
  72. X#define O_FETCH  19        /* the fetch character */
  73. X#define O_RADIX  20        /* the radix character */
  74. X#define O_RESC1  21        /* reserved char 1 */
  75. X#define O_RESC2  22        /* reserved char 2 */
  76. X#define O_RESC3  23        /* reserved char 3 */
  77. X#define O_RESC4  24        /* reserved char 4 */
  78. X#define O_SPACE  25        /* space character */
  79. X#define O_FCASE  26        /* case specific flag */
  80. X#define O_FBLANK 27        /* blank output line flag */
  81. X#define O_FSPACE 28        /* leading space flag */
  82. X#define O_FMATCH 29        /* required match flag */
  83. X#define O_FSYMGEN 30        /* symbol generator advance flag */
  84. X#define O_FSTACKUNDER 31    /* user stack underflow flag */
  85. X#define O_FSTACKSIZE  32    /* initial user stack size flag */
  86. X#define O_FECHO 33        /* echo flag */
  87. X#define O_RESF1 34        /* reserved flag 1 */
  88. X#define O_RESF2 35        /* reserved flag 2 */
  89. X#define O_RESF3 36        /* reserved flag 3 */
  90. X#define O_RESF4 37        /* reserved flag 4 */
  91. X#define O_last    38        /* size of parameter string */
  92. X
  93. Xextern char params[O_last]; /* inputted parameter string */
  94. X
  95. X    /* Format of macros in macrochar and macroflag:
  96. X     * header: flag = 0, val=char to match
  97. X     *           flag = 1, val='@' for placeholder
  98. X     *           flag = 2, val=0 for HEOL
  99. X     * body lines:
  100. X     *           flag = 0 to insert char in constructed line
  101. X     *           flag = 1, val='0'-'9' or 'C' or 'F' followed by
  102. X     *            flag = 1, val='0'-'9' for substitution
  103. X     *           flag=2, val=0 for BEOL
  104. X     *           flag=3, val=0 for end of body (after last BEOL)
  105. X     */
  106. X
  107. Xextern unsigned char * macrochar;   /* chars of macros (dyn alc) */
  108. Xextern unsigned char * macroflag;   /* flags of macros (dyn alc) */
  109. Xextern moffs macrosize;         /* size of macros loaded */
  110. X
  111. Xextern str varname[MAXvarnames];    /* names of variables */
  112. Xextern str varval[MAXvarnames];     /* values of variables */
  113. X
  114. Xextern str ustack[MAXustack];        /* values of user stack */
  115. Xextern short ustacksize;        /* # items on ustack */
  116. X
  117. Xstruct traceback_struct {    /* one entry on traceback stack */
  118. X    moffs retoffs;        /* macro offset to return to */
  119. X    str inp;            /* matched line */
  120. X    str p[10];            /* parameter values */
  121. X    };
  122. X
  123. Xextern struct traceback_struct tstack[MAXnests]; /* traceback stack */
  124. Xextern int tstacksize;
  125. X
  126. X#define Sretoffs (tstack[tstacksize-1].retoffs)
  127. X#define Sinp     (tstack[tstacksize-1].inp)
  128. X#define Sp     (tstack[tstacksize-1].p)
  129. X#define Sp0     (tstack[tstacksize-1].p[0])
  130. X#define Sp1     (tstack[tstacksize-1].p[1])
  131. X#define Sp2     (tstack[tstacksize-1].p[2])
  132. X#define Sp3     (tstack[tstacksize-1].p[3])
  133. X#define Sp4     (tstack[tstacksize-1].p[4])
  134. X#define Sp5     (tstack[tstacksize-1].p[5])
  135. X#define Sp6     (tstack[tstacksize-1].p[6])
  136. X#define Sp7     (tstack[tstacksize-1].p[7])
  137. X#define Sp8     (tstack[tstacksize-1].p[8])
  138. X#define Sp9     (tstack[tstacksize-1].p[9])
  139. X
  140. X#define ADDTOLINE(c) (consline[conslinesize++] = (c))
  141. X#define ENDLINE() (consline[conslinesize] = 0)
  142. X
  143. Xextern short sstack[MAXstreams];    /* input stream stack */
  144. Xextern short sstacksize;        /* # items on sstack */
  145. X
  146. Xextern short outstream;         /* current output stream */
  147. Xextern short instream;            /* current input stream */
  148. X
  149. Xextern char  consline[BIGLINE];     /* constructed line */
  150. Xextern short conslinesize;        /* chars on cons line */
  151. X
  152. Xextern long symgenval;            /* symbol generator value */
  153. X
  154. Xextern long skipping;            /* skip value flag */
  155. X
  156. Xextern bool quitting;            /* abnormally exitting */
  157. X
  158. X/* Functions: */
  159. X
  160. X    /* the two main functions */
  161. Xextern bool LoadMacros(int);    /* load macros from stream */
  162. Xextern void ParseFiles(int);    /* parse source from stream */
  163. X
  164. X    /* the support functions */
  165. Xextern void AddLineToStack(str);/* push and parse new line */
  166. Xextern int  BalMatch(str,str,char*);
  167. X                /* match balanced string */
  168. Xextern void FindMatch(void);    /* match input line on top of traceback */
  169. Xextern void ExpandLine(void);   /* expand macro on top of traceback */
  170. Xextern void DoCtrlOp(int);      /* do control op given as arg */
  171. Xextern void DoFileOp(int);      /* do file op given as arg */
  172. Xextern void DoSubsOp(int,int);  /* do substitution=arg2 on param=arg1 */
  173. X
  174. X    /* the general functions called from several places */
  175. Xextern void Message(str);       /* output a 4-char error message */
  176. Xextern void TraceBack(void);    /* display traceback */
  177. Xextern void PopTStack(void);    /* pop and discard top of traceback */
  178. Xextern void IntToStr(long,str); /* convert integer to string */
  179. Xextern long StrToInt(str);      /* convert string to integer */
  180. Xextern long StrToIntErr(str,str*);  /* convert string to integer w/ errors */
  181. Xextern void InsNumber(long);    /* insert text of number into line */
  182. Xextern str  VarLookup(str);     /* look up value of variable */
  183. Xextern void VarSetVal(str,str); /* set value of variable */
  184. X
  185. X
  186. END_OF_FILE
  187. if test 6152 -ne `wc -c <'LOME/LOME.h'`; then
  188.     echo shar: \"'LOME/LOME.h'\" unpacked with wrong size!
  189. fi
  190. # end of 'LOME/LOME.h'
  191. fi
  192. if test -f 'LOME/LOME.mac' -a "${1}" != "-c" ; then 
  193.   echo shar: Will not clobber existing file \"'LOME/LOME.mac'\"
  194. else
  195. echo shar: Extracting \"'LOME/LOME.mac'\" \(7493 characters\)
  196. sed "s/^X//" >'LOME/LOME.mac' <<'END_OF_FILE'
  197. XFILE: LOME.mac
  198. XThis is the input file for the regression testing of LOME.
  199. X
  200. X\@.@$0AaZFC`'()+-*/?!XXXX 011000000000
  201. XTest1a @
  202. XThis should say "`alpha '": "@00"
  203. XThis should say "alpha ": "@01"
  204. X$$
  205. X
  206. XTest1.
  207. XTesting parameter substitution ops...$This should not appear
  208. XThere should be exactly one blank line next
  209. X$ Nothing but a blank line should appear here
  210. XTest1a `alpha '$
  211. XThis should have nothing between quotes: "@00"
  212. XONEONE@27$    Assign "ONEONE" to parameter 2
  213. XThis should say "ONEONE": "@20"
  214. XFOUR@28$    set var ONEONE to FOUR
  215. XThis should say "FOUR": "@23"
  216. XThis should say "6": "@26"
  217. XThis should be I/O code for "O": "@25"
  218. XThis should say "0": "@55"
  219. XThis should say "0" also: "@56"
  220. XThree different numbers next: @54 @54 @54
  221. XThis should say "FOUR" again: "@24"
  222. XSIX@37$     Assign "SIX" to parameter 3
  223. XThis should say the same number three times: @34 @34 @34
  224. XThese are the I/O codes of A Z a z 0 + - * / ( ) ` ' ? !:
  225. XTest2Help A
  226. XTest2Help Z
  227. XTest2Help a
  228. XTest2Help z
  229. XTest2Help 0
  230. XTest2Help +
  231. XTest2Help -
  232. XTest2Help *
  233. XTest2Help /
  234. XTest2Help (
  235. XTest2Help )
  236. XTest2Help `
  237. XTest2Help '
  238. XTest2Help ?
  239. XTest2Help !
  240. XTesting substitution ops (except math) complete!
  241. X$$
  242. X
  243. XTest2Help @.
  244. XThe I/O code for "@00" is "@05"
  245. X$$
  246. X
  247. XTest3.        test control ops
  248. XTesting control ops...
  249. XTest3a$     test skips single case
  250. XTest3c$     test push and pop
  251. X$$
  252. XTest3a.     test skips single case
  253. XThis tests skips next. Following lines should be numbered and consecutive.
  254. XIf a line starting with X appears, an error exists.
  255. X01 - About to test skip eq
  256. XSkip 1 if xyzzy eq xyzzy
  257. XXA - If this appears, skip eq does not skip on eq
  258. XSkip 1 if xyzzy eq pdq
  259. X02 - If this does not appear, skip eq skips on ne
  260. X03 - End test of skip eq. About to test skip ne.
  261. XSkip 1 if lotus ne xyzzy
  262. XXB - If this appears, skip ne does not skip on ne
  263. XSkip 1 if lotus ne lotus
  264. X04 - If this does not appear, skip ne skips on eq
  265. X05 - end test of skip ne. about to test skip lt.
  266. XSkip 1 if 100 lt 100
  267. X06 - If this does not appear, 100 lt 100 skips
  268. XSkip 1 if 100 lt 200
  269. XXC - If this appears, 100 lt 200 did not skip
  270. XSkip 1 if -100 lt 50
  271. XXD - If this appears, -100 lt 200 did not skip
  272. XSkip 1 if 50 lt -100
  273. X07 - If this does not appear, 50 lt -100 skips
  274. X08 - end test of skip lt. about to test skip begins.
  275. XSkip 1 if xyzzy begins xyzzypdq
  276. XXE - If this appears, xyzzy begins xyzzypdq does not skip
  277. XSkip 1 if xyzzy begins xyzzy
  278. XXF - If this appears, xyzzy begins xyzzy does not skip
  279. XSkip 1 if xyzzy begins xyzz
  280. X09 - If this does not appear, xyzzy begins xyzz skips
  281. X10 - About to test multi-level skips
  282. XTest3b1
  283. X11 - End of numbered lines (for now)
  284. X$$
  285. XTest3b1.
  286. XTest3b2
  287. XXX - Multi level skip not skipping enough
  288. X$$
  289. XTest3b2.
  290. XTest3b3
  291. XXX - Multi level skip not skipping enough
  292. X$$
  293. XTest3b3.
  294. XSkip -4 if 0 lt 1$    -4 because Skip @ if @ lt @ is also a macro
  295. XXX - Multi level skip not skipping enough
  296. X$$
  297. XTest3c.     test push and pop
  298. XONE@C5TWO@C5THREE@C5
  299. X2@C6
  300. X@C6
  301. X3@C6
  302. XThis should say "THREE ONE": "@20 @30"
  303. X$$
  304. X
  305. XTest4.    Test skipping input directly
  306. XAbout to test input skipping.
  307. XSkip 3 if 1 lt 2
  308. XXX - This should not appear.
  309. X$$
  310. XSkip @ if @ eq @.        string equal comparison
  311. X@C2$
  312. X$$
  313. XSkip @ if @ ne @.        string notequal comparison.
  314. X@C3$
  315. X$$
  316. XSkip @ if @ lt @.        numeric lessthan comparison.
  317. X@C1$
  318. X$$
  319. XSkip @ if @ begins @.        initial string comparison.
  320. X@C4$
  321. X$$
  322. X
  323. XTest5.            Decimal Loop constructs
  324. XStart Decimal Loop Tests
  325. XThis should print "test5a:(-3)" through "test5a:(19)" and then "stuff"
  326. XDecimal loop -3 19 test5a:
  327. XThe next line should say "test5b:(5)" and then "stuff"
  328. XDecimal loop 5 5 test5b:
  329. XThe next line should say "stuff" and then "no loop" w/o anything between
  330. XDecimal loop 8 7 test5c:
  331. Xno loop
  332. XThis should say "test5d1:(1)" and "test5d1:(2)" and then NO "stuff"
  333. XDecimal loop 1 5 test5d:
  334. XEnd Decimal Loop Tests
  335. X$$
  336. XDecimal loop @ @ @
  337. X@21@C7stuff
  338. X$$
  339. Xtest5d:(@).
  340. XSkip -3 if @00 eq 3
  341. Xtest5d1:(@00)
  342. X$$
  343. X
  344. XTest6.            String Loop constructs
  345. XStart String Loop Tests
  346. XThis should say "t6:A" "t6:C" "t6:F" and then "stuff"
  347. XString loop !ACF!!t6:!
  348. XThis should print out the eval example from the docs
  349. XString loop !AB+(B*CD)*E+-FG!+-*/!EVAL!
  350. XThis should print out the XX example from the docs
  351. XAB(CD`@07
  352. X()`'@17
  353. XXX@C8
  354. XEnd String Loop Tests
  355. X$$
  356. XString loop !@!@!@!
  357. X@21@C8stuff
  358. X$$
  359. X
  360. XTest7a.             Test some file ops
  361. X1VERY IMPORTANT TEST MESSAGE SHOULD GO TO CONSOLE@F7
  362. X9note not so very imporant test message should be suppressed@F7
  363. XX-X-X-X-X ONE
  364. X4@F2$            send output to stream 4
  365. XFish Fish Fish
  366. XThis line should go onto stream 4 and then be copied to output.
  367. XThis should also go to stream 4 and be copied to output also.
  368. XOnce more this goes to stream 4 and back.
  369. XEND OF INPUT
  370. X3@F2$            reset output back to stream 3 again
  371. XX-X-X-X-X TWO
  372. X4@F0$            rewind stream 4
  373. X4ZEND OF INPUT@F1$  copy stream 4 to input until "END OF INPUT" found
  374. XX-X-X-X-X THREE
  375. X4@F0$            rewind stream 4
  376. X4X@F3$            read stream four and revert at EOF
  377. X$$            force input stream 4 to read
  378. XTest7b.             more file operations
  379. XX-X-X-X-X FOUR
  380. X4@F0$            rewind stream 4
  381. X47@F8$            read a line from 4 and put it in P7
  382. XX-X-X-X-X FIVE
  383. XThis should say "Fish Fish Fish": "@70"
  384. XZThe next line should say "TestMath" only@F4
  385. XZTestMath@F4
  386. XThis should output the F5 example from LOME.doc:
  387. XZERO@0723@17
  388. XZ 000000 11111 000 HELP22ME@F5
  389. XX-X-X-X-X SIX
  390. X49@F1$            Copy stream 4 from current to EOF to scratch 9
  391. X9@F0$            rewind scratch 9
  392. X9Z@F1$            Copy 9 to output until EOF
  393. XX-X-X-X-X SEVEN
  394. X9@F0$            rewind nine again
  395. X9ZOnce@F1$        copy it again, stopping at Once...
  396. XX-X-X-X-X EIGHT
  397. X9t:LOME9.out@F0$    rewind nine and rename it to t:LOME9.out
  398. X9This should go only to t:LOME9.out@F4
  399. XX-X-X-X-X NINE
  400. X$$
  401. X
  402. XTestMath.
  403. XTest mathematical substitutions:
  404. XZIP@07$     put "ZIP" into parameter zero
  405. X7294@08$    put "7294" into variable ZIP
  406. XNo operators: This should say "ZIP": "@02"
  407. X3 9 +@27
  408. XAddition: This should say "12": "@22"
  409. X3 9 *@27
  410. XMultiplication: This should say "27": "@22"
  411. X143 149 -@27
  412. XSubtraction: This should say "-6": "@22"
  413. X3 9 /@27
  414. XDivision w/ truncation: This should say "0": "@22"
  415. X-34 5 /@27
  416. XDivision w/o truncation: This should say "-6": "@22"
  417. X  -25 @27
  418. XLeading minus: This should say "-25": "@22"
  419. X   25  5 *   18 3 / + -1 *  @27
  420. XComplex formulas with leading minuses: This should say "-131": "@22"
  421. XZIP ?@17$   put "ZIP ?" into parameter one
  422. XFetch: This should say "7294": "@12"
  423. X ZIP ? @17$ put " ZIP ? " into parameter one
  424. XFetch with extra spaces: This should say "7294": "@12"
  425. XZIP ? 18 /@17
  426. XFetch then math: This should say "405": "@12"
  427. X  +3 +12 -2 / +3 * *@27
  428. XComplex leading plusses and minuses: this should say "-54": "@22"
  429. XRadix tests:
  430. XThe following should give 0 to 9 and A to Z after TM1a: and then stuff
  431. XDecimal loop 0 35 TM1:
  432. XThe following should give -Z to -A and -9 to -1 and 0 after TM1a: and then stuff
  433. XDecimal loop -35 0 TM1:
  434. XThe following should give -2Z to -20 to -1Z to -10 to -Z to -1 to 0
  435. XDecimal loop -107 0 TM1:
  436. XThe following should give 0 to 35 after TM3a: and then stuff
  437. XString loop !0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!!TM3:!
  438. XThe following should give 0 to 35 again after TM3a: and then stuff
  439. XString loop !0123456789abcdefghijklmnopqrstuvwxyz!!TM3:!
  440. XThe following should give 2 to 36 after TM3a: and then stuff
  441. XString loop !123456789ABCDEFGHIJKLNNOPQRSTUVWXYZ!!TM3b:!
  442. XThe following should count from 0 to 15 in binary after TM4a: and then stuff
  443. XDecimal loop 0 15 TM4:
  444. X  +100 9 Z !@27
  445. XRadix with leading plusses: This should say "2S": "@22"
  446. XEnd of radix tests.
  447. X$$
  448. XTM4:(@).
  449. X@00 9 1 !@27TM4a:@22
  450. X$$
  451. XTM3b:@.
  452. X10 @00 9 !@27TM3a:@22
  453. X$$
  454. XTM3:@.
  455. X@00 z 9 !@27TM3a:@22
  456. X$$
  457. XTM2:(@).
  458. X@00 Z 9 !@27TM2a:@22
  459. X$$
  460. XTM1:(@).
  461. X@00 9 Z !@27TM1a:@22
  462. X$$
  463. X
  464. X
  465. END_OF_FILE
  466. if test 7493 -ne `wc -c <'LOME/LOME.mac'`; then
  467.     echo shar: \"'LOME/LOME.mac'\" unpacked with wrong size!
  468. fi
  469. # end of 'LOME/LOME.mac'
  470. fi
  471. if test -f 'LOME/LOME1.out' -a "${1}" != "-c" ; then 
  472.   echo shar: Will not clobber existing file \"'LOME/LOME1.out'\"
  473. else
  474. echo shar: Extracting \"'LOME/LOME1.out'\" \(7500 characters\)
  475. sed "s/^X//" >'LOME/LOME1.out' <<'END_OF_FILE'
  476. XThis line should come out unchanged
  477. XTesting parameter substitution ops...
  478. XThere should be exactly one blank line next
  479. X
  480. XThis should say "`alpha '": "`alpha '"
  481. XThis should say "alpha ": "alpha "
  482. XThis should have nothing between quotes: ""
  483. XThis should say "ONEONE": "ONEONE"
  484. XThis should say "FOUR": "FOUR"
  485. XThis should say "6": "6"
  486. XThis should be I/O code for "O": "79"
  487. XThis should say "0": "0"
  488. XThis should say "0" also: "0"
  489. XThree different numbers next: 0 1 2
  490. XThis should say "FOUR" again: "FOUR"
  491. XThis should say the same number three times: 3 3 3
  492. XThese are the I/O codes of A Z a z 0 + - * / ( ) ` ' ? !:
  493. XThe I/O code for "A" is "65"
  494. XThe I/O code for "Z" is "90"
  495. XThe I/O code for "a" is "97"
  496. XThe I/O code for "z" is "122"
  497. XThe I/O code for "0" is "48"
  498. XThe I/O code for "+" is "43"
  499. XThe I/O code for "-" is "45"
  500. XThe I/O code for "*" is "42"
  501. XThe I/O code for "/" is "47"
  502. XThe I/O code for "(" is "40"
  503. XThe I/O code for ")" is "41"
  504. XThe I/O code for "`" is "96"
  505. XThe I/O code for "'" is "39"
  506. XThe I/O code for "?" is "63"
  507. XThe I/O code for "!" is "33"
  508. XTesting substitution ops (except math) complete!
  509. XTest2
  510. XTesting control ops...
  511. XThis tests skips next. Following lines should be numbered and consecutive.
  512. XIf a line starting with X appears, an error exists.
  513. X01 - About to test skip eq
  514. X02 - If this does not appear, skip eq skips on ne
  515. X03 - End test of skip eq. About to test skip ne.
  516. X04 - If this does not appear, skip ne skips on eq
  517. X05 - end test of skip ne. about to test skip lt.
  518. X06 - If this does not appear, 100 lt 100 skips
  519. X07 - If this does not appear, 50 lt -100 skips
  520. X08 - end test of skip lt. about to test skip begins.
  521. X09 - If this does not appear, xyzzy begins xyzz skips
  522. X10 - About to test multi-level skips
  523. X11 - End of numbered lines (for now)
  524. XThis should say "THREE ONE": "THREE ONE"
  525. XAbout to test input skipping.
  526. XIf this does not appear, input skips skipping too much
  527. XStart Decimal Loop Tests
  528. XThis should print "test5a:(-3)" through "test5a:(19)" and then "stuff"
  529. Xtest5a:(-3)
  530. Xtest5a:(-2)
  531. Xtest5a:(-1)
  532. Xtest5a:(0)
  533. Xtest5a:(1)
  534. Xtest5a:(2)
  535. Xtest5a:(3)
  536. Xtest5a:(4)
  537. Xtest5a:(5)
  538. Xtest5a:(6)
  539. Xtest5a:(7)
  540. Xtest5a:(8)
  541. Xtest5a:(9)
  542. Xtest5a:(10)
  543. Xtest5a:(11)
  544. Xtest5a:(12)
  545. Xtest5a:(13)
  546. Xtest5a:(14)
  547. Xtest5a:(15)
  548. Xtest5a:(16)
  549. Xtest5a:(17)
  550. Xtest5a:(18)
  551. Xtest5a:(19)
  552. Xstuff
  553. XThe next line should say "test5b:(5)" and then "stuff"
  554. Xtest5b:(5)
  555. Xstuff
  556. XThe next line should say "stuff" and then "no loop" w/o anything between
  557. Xstuff
  558. Xno loop
  559. XThis should say "test5d1:(1)" and "test5d1:(2)" and then NO "stuff"
  560. Xtest5d1:(1)
  561. Xtest5d1:(2)
  562. XEnd Decimal Loop Tests
  563. XStart String Loop Tests
  564. XThis should say "t6:A" "t6:C" "t6:F" and then "stuff"
  565. Xt6:A
  566. Xt6:C
  567. Xt6:F
  568. Xstuff
  569. XThis should print out the eval example from the docs
  570. XEVAL(+)AB
  571. XEVAL(*)(B*CD)
  572. XEVAL(+)E
  573. XEVAL(-)
  574. XEVAL()FG
  575. Xstuff
  576. XThis should print out the XX example from the docs
  577. XXX(\()AB
  578. XXX(`)CD
  579. XEnd String Loop Tests
  580. XX-X-X-X-X ONE
  581. XX-X-X-X-X TWO
  582. XFish Fish Fish
  583. XThis line should go onto stream 4 and then be copied to output.
  584. XThis should also go to stream 4 and be copied to output also.
  585. XOnce more this goes to stream 4 and back.
  586. XX-X-X-X-X THREE
  587. XFish Fish Fish
  588. XThis line should go onto stream 4 and then be copied to output
  589. XThis should also go to stream 4 and be copied to output also
  590. XOnce more this goes to stream 4 and back
  591. XEND OF INPUT
  592. XX-X-X-X-X FOUR
  593. XX-X-X-X-X FIVE
  594. XThis should say "Fish Fish Fish": "Fish Fish Fish"
  595. XThe next line should say "TestMath" only
  596. XTestMath
  597. XThis should output the F5 example from LOME.doc:
  598. X ZERO   23    ZER HELP  ME
  599. XX-X-X-X-X SIX
  600. XThis line should go onto stream 4 and then be copied to output.
  601. XThis should also go to stream 4 and be copied to output also.
  602. XOnce more this goes to stream 4 and back.
  603. XEND OF INPUT
  604. XX-X-X-X-X SEVEN
  605. XThis line should go onto stream 4 and then be copied to output.
  606. XThis should also go to stream 4 and be copied to output also.
  607. XX-X-X-X-X EIGHT
  608. XX-X-X-X-X NINE
  609. XTest mathematical substitutions:
  610. XNo operators: This should say "ZIP": "ZIP"
  611. XAddition: This should say "12": "12"
  612. XMultiplication: This should say "27": "27"
  613. XSubtraction: This should say "-6": "-6"
  614. XDivision w/ truncation: This should say "0": "0"
  615. XDivision w/o truncation: This should say "-6": "-6"
  616. XLeading minus: This should say "-25": "-25"
  617. XComplex formulas with leading minuses: This should say "-131": "-131"
  618. XFetch: This should say "7294": "7294"
  619. XFetch with extra spaces: This should say "7294": "7294"
  620. XFetch then math: This should say "405": "405"
  621. XComplex leading plusses and minuses: this should say "-54": "-54"
  622. XRadix tests:
  623. XThe following should give 0 to 9 and A to Z after TM1a: and then stuff
  624. XTM1a:0
  625. XTM1a:1
  626. XTM1a:2
  627. XTM1a:3
  628. XTM1a:4
  629. XTM1a:5
  630. XTM1a:6
  631. XTM1a:7
  632. XTM1a:8
  633. XTM1a:9
  634. XTM1a:A
  635. XTM1a:B
  636. XTM1a:C
  637. XTM1a:D
  638. XTM1a:E
  639. XTM1a:F
  640. XTM1a:G
  641. XTM1a:H
  642. XTM1a:I
  643. XTM1a:J
  644. XTM1a:K
  645. XTM1a:L
  646. XTM1a:M
  647. XTM1a:N
  648. XTM1a:O
  649. XTM1a:P
  650. XTM1a:Q
  651. XTM1a:R
  652. XTM1a:S
  653. XTM1a:T
  654. XTM1a:U
  655. XTM1a:V
  656. XTM1a:W
  657. XTM1a:X
  658. XTM1a:Y
  659. XTM1a:Z
  660. Xstuff
  661. XThe following should give -Z to -A and -9 to -1 and 0 after TM1a: and then stuff
  662. XTM1a:-Z
  663. XTM1a:-Y
  664. XTM1a:-X
  665. XTM1a:-W
  666. XTM1a:-V
  667. XTM1a:-U
  668. XTM1a:-T
  669. XTM1a:-S
  670. XTM1a:-R
  671. XTM1a:-Q
  672. XTM1a:-P
  673. XTM1a:-O
  674. XTM1a:-N
  675. XTM1a:-M
  676. XTM1a:-L
  677. XTM1a:-K
  678. XTM1a:-J
  679. XTM1a:-I
  680. XTM1a:-H
  681. XTM1a:-G
  682. XTM1a:-F
  683. XTM1a:-E
  684. XTM1a:-D
  685. XTM1a:-C
  686. XTM1a:-B
  687. XTM1a:-A
  688. XTM1a:-9
  689. XTM1a:-8
  690. XTM1a:-7
  691. XTM1a:-6
  692. XTM1a:-5
  693. XTM1a:-4
  694. XTM1a:-3
  695. XTM1a:-2
  696. XTM1a:-1
  697. XTM1a:0
  698. Xstuff
  699. XThe following should give -2Z to -20 to -1Z to -10 to -Z to -1 to 0
  700. XTM1a:-2Z
  701. XTM1a:-2Y
  702. XTM1a:-2X
  703. XTM1a:-2W
  704. XTM1a:-2V
  705. XTM1a:-2U
  706. XTM1a:-2T
  707. XTM1a:-2S
  708. XTM1a:-2R
  709. XTM1a:-2Q
  710. XTM1a:-2P
  711. XTM1a:-2O
  712. XTM1a:-2N
  713. XTM1a:-2M
  714. XTM1a:-2L
  715. XTM1a:-2K
  716. XTM1a:-2J
  717. XTM1a:-2I
  718. XTM1a:-2H
  719. XTM1a:-2G
  720. XTM1a:-2F
  721. XTM1a:-2E
  722. XTM1a:-2D
  723. XTM1a:-2C
  724. XTM1a:-2B
  725. XTM1a:-2A
  726. XTM1a:-29
  727. XTM1a:-28
  728. XTM1a:-27
  729. XTM1a:-26
  730. XTM1a:-25
  731. XTM1a:-24
  732. XTM1a:-23
  733. XTM1a:-22
  734. XTM1a:-21
  735. XTM1a:-20
  736. XTM1a:-1Z
  737. XTM1a:-1Y
  738. XTM1a:-1X
  739. XTM1a:-1W
  740. XTM1a:-1V
  741. XTM1a:-1U
  742. XTM1a:-1T
  743. XTM1a:-1S
  744. XTM1a:-1R
  745. XTM1a:-1Q
  746. XTM1a:-1P
  747. XTM1a:-1O
  748. XTM1a:-1N
  749. XTM1a:-1M
  750. XTM1a:-1L
  751. XTM1a:-1K
  752. XTM1a:-1J
  753. XTM1a:-1I
  754. XTM1a:-1H
  755. XTM1a:-1G
  756. XTM1a:-1F
  757. XTM1a:-1E
  758. XTM1a:-1D
  759. XTM1a:-1C
  760. XTM1a:-1B
  761. XTM1a:-1A
  762. XTM1a:-19
  763. XTM1a:-18
  764. XTM1a:-17
  765. XTM1a:-16
  766. XTM1a:-15
  767. XTM1a:-14
  768. XTM1a:-13
  769. XTM1a:-12
  770. XTM1a:-11
  771. XTM1a:-10
  772. XTM1a:-Z
  773. XTM1a:-Y
  774. XTM1a:-X
  775. XTM1a:-W
  776. XTM1a:-V
  777. XTM1a:-U
  778. XTM1a:-T
  779. XTM1a:-S
  780. XTM1a:-R
  781. XTM1a:-Q
  782. XTM1a:-P
  783. XTM1a:-O
  784. XTM1a:-N
  785. XTM1a:-M
  786. XTM1a:-L
  787. XTM1a:-K
  788. XTM1a:-J
  789. XTM1a:-I
  790. XTM1a:-H
  791. XTM1a:-G
  792. XTM1a:-F
  793. XTM1a:-E
  794. XTM1a:-D
  795. XTM1a:-C
  796. XTM1a:-B
  797. XTM1a:-A
  798. XTM1a:-9
  799. XTM1a:-8
  800. XTM1a:-7
  801. XTM1a:-6
  802. XTM1a:-5
  803. XTM1a:-4
  804. XTM1a:-3
  805. XTM1a:-2
  806. XTM1a:-1
  807. XTM1a:0
  808. Xstuff
  809. XThe following should give 0 to 35 after TM3a: and then stuff
  810. XTM3a:0
  811. XTM3a:1
  812. XTM3a:2
  813. XTM3a:3
  814. XTM3a:4
  815. XTM3a:5
  816. XTM3a:6
  817. XTM3a:7
  818. XTM3a:8
  819. XTM3a:9
  820. XTM3a:10
  821. XTM3a:11
  822. XTM3a:12
  823. XTM3a:13
  824. XTM3a:14
  825. XTM3a:15
  826. XTM3a:16
  827. XTM3a:17
  828. XTM3a:18
  829. XTM3a:19
  830. XTM3a:20
  831. XTM3a:21
  832. XTM3a:22
  833. XTM3a:23
  834. XTM3a:24
  835. XTM3a:25
  836. XTM3a:26
  837. XTM3a:27
  838. XTM3a:28
  839. XTM3a:29
  840. XTM3a:30
  841. XTM3a:31
  842. XTM3a:32
  843. XTM3a:33
  844. XTM3a:34
  845. XTM3a:35
  846. Xstuff
  847. XThe following should give 0 to 35 again after TM3a: and then stuff
  848. XTM3a:0
  849. XTM3a:1
  850. XTM3a:2
  851. XTM3a:3
  852. XTM3a:4
  853. XTM3a:5
  854. XTM3a:6
  855. XTM3a:7
  856. XTM3a:8
  857. XTM3a:9
  858. XTM3a:10
  859. XTM3a:11
  860. XTM3a:12
  861. XTM3a:13
  862. XTM3a:14
  863. XTM3a:15
  864. XTM3a:16
  865. XTM3a:17
  866. XTM3a:18
  867. XTM3a:19
  868. XTM3a:20
  869. XTM3a:21
  870. XTM3a:22
  871. XTM3a:23
  872. XTM3a:24
  873. XTM3a:25
  874. XTM3a:26
  875. XTM3a:27
  876. XTM3a:28
  877. XTM3a:29
  878. XTM3a:30
  879. XTM3a:31
  880. XTM3a:32
  881. XTM3a:33
  882. XTM3a:34
  883. XTM3a:35
  884. Xstuff
  885. XThe following should give 2 to 36 after TM3a: and then stuff
  886. XTM3a:2
  887. XTM3a:3
  888. XTM3a:4
  889. XTM3a:5
  890. XTM3a:6
  891. XTM3a:7
  892. XTM3a:8
  893. XTM3a:9
  894. XTM3a:10
  895. XTM3a:11
  896. XTM3a:12
  897. XTM3a:13
  898. XTM3a:14
  899. XTM3a:15
  900. XTM3a:16
  901. XTM3a:17
  902. XTM3a:18
  903. XTM3a:19
  904. XTM3a:20
  905. XTM3a:21
  906. XTM3a:22
  907. XTM3a:24
  908. XTM3a:24
  909. XTM3a:25
  910. XTM3a:26
  911. XTM3a:27
  912. XTM3a:28
  913. XTM3a:29
  914. XTM3a:30
  915. XTM3a:31
  916. XTM3a:32
  917. XTM3a:33
  918. XTM3a:34
  919. XTM3a:35
  920. XTM3a:36
  921. Xstuff
  922. XThe following should count from 0 to 15 in binary after TM4a: and then stuff
  923. XTM4a:0
  924. XTM4a:1
  925. XTM4a:10
  926. XTM4a:11
  927. XTM4a:100
  928. XTM4a:101
  929. XTM4a:110
  930. XTM4a:111
  931. XTM4a:1000
  932. XTM4a:1001
  933. XTM4a:1010
  934. XTM4a:1011
  935. XTM4a:1100
  936. XTM4a:1101
  937. XTM4a:1110
  938. XTM4a:1111
  939. Xstuff
  940. XRadix with leading plusses: This should say "2S": "2S"
  941. XEnd of radix tests.
  942. XEnd of Tests!
  943. END_OF_FILE
  944. if test 7500 -ne `wc -c <'LOME/LOME1.out'`; then
  945.     echo shar: \"'LOME/LOME1.out'\" unpacked with wrong size!
  946. fi
  947. # end of 'LOME/LOME1.out'
  948. fi
  949. if test -f 'LOME/LOME5.c' -a "${1}" != "-c" ; then 
  950.   echo shar: Will not clobber existing file \"'LOME/LOME5.c'\"
  951. else
  952. echo shar: Extracting \"'LOME/LOME5.c'\" \(6778 characters\)
  953. sed "s/^X//" >'LOME/LOME5.c' <<'END_OF_FILE'
  954. X/*
  955. X * LOME5.c
  956. X * Line Oriented Macro Expander - DoCtrlOp()
  957. X * Copyright 1989 Darren New
  958. X *
  959. X */
  960. X
  961. X#include "LOME.h"
  962. X
  963. Xvoid DoCtrlOp ARGS1(int,op /* the operation number */)
  964. X{
  965. X    int i;
  966. X
  967. X    assert(0 < tstacksize);
  968. X
  969. X    switch (op) {
  970. X
  971. X    case 0: {    /* stop */
  972. X        if (conslinesize != 0) {
  973. X        char * t = consline;
  974. X        MPutChar(0);
  975. X        while (*t) MPutChar(*t++);
  976. X        MPutChar(0);
  977. X        MPutBuff(outstream);
  978. X        TraceBack();
  979. X        }
  980. X        quitting = TRUE;
  981. X        break;
  982. X        }
  983. X
  984. X    case 1: {    /* skip p0 if val(p1) < val(p2) */
  985. X        if (StrToInt(Sp1) < StrToInt(Sp2)) {
  986. X        skipping = StrToInt(Sp0);
  987. X        while (macroflag[Sretoffs] != 2)
  988. X            Sretoffs += 1;
  989. X        }
  990. X        break;
  991. X        }
  992. X
  993. X    case 2: {    /* skip p0 if "p1" eq "p2" */
  994. X
  995. X        bool m = TRUE;    /* matched? */
  996. X        bool c = params[O_FCASE] == params[O_ZERO]; /* case indep? */
  997. X        char c1, c2;    /* chars being compared */
  998. X
  999. X        if (Sp1 == NULL) Sp1 = PLStrDup("");
  1000. X        if (Sp2 == NULL) Sp2 = PLStrDup("");
  1001. X
  1002. X        if (strlen(Sp1) != strlen(Sp2)) m = FALSE;
  1003. X
  1004. X        for (i = 0; m && (c1 = Sp1[i]) && (c2 = Sp2[i]); i++) {
  1005. X        m = c1 == c2;
  1006. X        if (!m && c) {
  1007. X            /* see if case independence will match */
  1008. X            if (params[O_UCA] <= c1 && c1 <= params[O_UCZ])
  1009. X            c1 = c1 - params[O_UCA] + params[O_LCA];
  1010. X            if (params[O_UCA] <= c2 && c2 <= params[O_UCZ])
  1011. X            c2 = c2 - params[O_UCA] + params[O_LCA];
  1012. X            m = c1 == c2;
  1013. X            }
  1014. X        }
  1015. X
  1016. X        if (m) {
  1017. X        skipping = StrToInt(Sp0);
  1018. X        while (macroflag[Sretoffs] != 2)
  1019. X            Sretoffs += 1;
  1020. X        }
  1021. X
  1022. X        break;
  1023. X        }
  1024. X
  1025. X    case 3: {    /* skip p0 if "p1" ne "p2" */
  1026. X
  1027. X        bool m = TRUE;    /* matched? */
  1028. X        bool c = params[O_FCASE] == params[O_ZERO]; /* case indep? */
  1029. X        char c1, c2;    /* chars being compared */
  1030. X
  1031. X        if (Sp1 == NULL) Sp1 = PLStrDup("");
  1032. X        if (Sp2 == NULL) Sp2 = PLStrDup("");
  1033. X
  1034. X        if (strlen(Sp1) != strlen(Sp2)) m = FALSE;
  1035. X
  1036. X        for (i = 0; m && (c1 = Sp1[i]) && (c2 = Sp2[i]); i++) {
  1037. X        m = c1 == c2;
  1038. X        if (!m && c) {
  1039. X            /* see if case independence will match */
  1040. X            if (params[O_UCA] <= c1 && c1 <= params[O_UCZ])
  1041. X            c1 = c1 - params[O_UCA] + params[O_LCA];
  1042. X            if (params[O_UCA] <= c2 && c2 <= params[O_UCZ])
  1043. X            c2 = c2 - params[O_UCA] + params[O_LCA];
  1044. X            m = c1 == c2;
  1045. X            }
  1046. X        }
  1047. X
  1048. X        if (!m) {
  1049. X        skipping = StrToInt(Sp0);
  1050. X        while (macroflag[Sretoffs] != 2)
  1051. X            Sretoffs += 1;
  1052. X        }
  1053. X
  1054. X        break;
  1055. X        }
  1056. X
  1057. X    case 4: {    /* skip p0 if "p1" starts "p2" */
  1058. X
  1059. X        bool m = TRUE;    /* matched? */
  1060. X        bool c = params[O_FCASE] == params[O_ZERO]; /* case indep? */
  1061. X        char c1, c2;    /* chars being compared */
  1062. X
  1063. X        if (Sp1 == NULL) Sp1 = PLStrDup("");
  1064. X        if (Sp2 == NULL) Sp2 = PLStrDup("");
  1065. X
  1066. X        for (i = 0; m && (c1 = Sp1[i]) && (c2 = Sp2[i]); i++) {
  1067. X        m = c1 == c2;
  1068. X        if (!m && c) {
  1069. X            /* see if case independence will match */
  1070. X            if (params[O_UCA] <= c1 && c1 <= params[O_UCZ])
  1071. X            c1 = c1 - params[O_UCA] + params[O_LCA];
  1072. X            if (params[O_UCA] <= c2 && c2 <= params[O_UCZ])
  1073. X            c2 = c2 - params[O_UCA] + params[O_LCA];
  1074. X            m = c1 == c2;
  1075. X            }
  1076. X        }
  1077. X
  1078. X        if (Sp1[i] == 0) {
  1079. X        skipping = StrToInt(Sp0);
  1080. X        while (macroflag[Sretoffs] != 2)
  1081. X            Sretoffs += 1;
  1082. X        }
  1083. X
  1084. X        break;
  1085. X        }
  1086. X
  1087. X    case 5: {    /* push ustack */
  1088. X        if (ustacksize == MAXustack) {
  1089. X        Message("FSTK");
  1090. X        TraceBack();
  1091. X        quitting = TRUE;
  1092. X        }
  1093. X        else {
  1094. X        ustack[ustacksize++] = PLStrDup(consline);
  1095. X        }
  1096. X        break;
  1097. X        }
  1098. X
  1099. X    case 6: {    /* pop ustack */
  1100. X        if (0 < ustacksize) {
  1101. X        if (0 < conslinesize) {
  1102. X            int p = consline[0] - params[O_ZERO];
  1103. X            if (0 <= p && p <= 9) {
  1104. X            if (Sp[p]) PLFreeMem(Sp[p]);
  1105. X            Sp[p] = PLStrDup(ustack[ustacksize-1]);
  1106. X            }
  1107. X            else {
  1108. X            Message("FORM");
  1109. X            TraceBack();
  1110. X            quitting = TRUE;
  1111. X            }
  1112. X            }
  1113. X        ustacksize -= 1;
  1114. X        PLFreeMem(ustack[ustacksize]);
  1115. X        ustack[ustacksize] = NULL;
  1116. X        }
  1117. X        else {
  1118. X        if (params[O_ZERO] == params[O_FSTACKUNDER]) {
  1119. X            Message("ESTK");
  1120. X            TraceBack();
  1121. X            quitting = TRUE;
  1122. X            }
  1123. X        }
  1124. X        break;
  1125. X        }
  1126. X
  1127. X    case 7: {    /* decimal loop */
  1128. X        char buf[BIGLINE];
  1129. X        long p0 = StrToInt(Sp0);
  1130. X        long p1 = StrToInt(Sp1);
  1131. X        if (p0 <= p1) {
  1132. X        /* build new macro line */
  1133. X        ADDTOLINE(params[O_OP]);
  1134. X        InsNumber(p0);
  1135. X        ADDTOLINE(params[O_CP]);
  1136. X        ENDLINE();
  1137. X        /* update local parameters for next iteration */
  1138. X        if (Sp0 != NULL) PLFreeMem(Sp0);
  1139. X        IntToStr(p0 + 1, buf);
  1140. X        Sp0 = PLStrDup(buf);
  1141. X        /* patch return stack by looking for prev BEOL or HEOL */
  1142. X        while (macroflag[Sretoffs -= 1] != 2)
  1143. X            ;
  1144. X        Sretoffs += 1;
  1145. X        /* after patching my ret addr, add new stack frame */
  1146. X        AddLineToStack(consline);
  1147. X        }
  1148. X        break;
  1149. X        }
  1150. X
  1151. X    case 8: {    /* string loop */
  1152. X        char buf[BIGLINE];
  1153. X        if (Sp0 && *Sp0) {
  1154. X        if (Sp1 == NULL || *Sp1 == 0) { /* individual characters */
  1155. X            /* build constructed line */
  1156. X            ADDTOLINE(*Sp0);
  1157. X            ENDLINE();
  1158. X            /* update local parameters for next iteration */
  1159. X            strcpy(buf, Sp0 + 1);
  1160. X            PLFreeMem(Sp0);
  1161. X            Sp0 = PLStrDup(buf);
  1162. X            }
  1163. X        else {        /* groups of characters */
  1164. X            char next;
  1165. X            int mlen;
  1166. X            /* match string */
  1167. X            mlen = BalMatch(Sp0, Sp1, &next);
  1168. X            if (next) {     /* not at end */
  1169. X            ADDTOLINE(params[O_OP]);
  1170. X            if (next == params[O_OP] || next == params[O_CP])
  1171. X                ADDTOLINE(params[O_ESC]);
  1172. X            ADDTOLINE(next);
  1173. X            ADDTOLINE(params[O_CP]);
  1174. X            for (i = 0; i < mlen; i++)
  1175. X                ADDTOLINE(Sp0[i]);
  1176. X            }
  1177. X            else {        /* at end */
  1178. X            ADDTOLINE(params[O_OP]);
  1179. X            ADDTOLINE(params[O_CP]);
  1180. X            for (i = 0; i < mlen; i++)
  1181. X                ADDTOLINE(Sp0[i]);
  1182. X            }
  1183. X            ENDLINE();
  1184. X            if (Sp0[mlen]) {    /* still some left */
  1185. X            strcpy(buf, &Sp0[mlen + 1]);  /* skip mchars too */
  1186. X            PLFreeMem(Sp0);
  1187. X            Sp0 = PLStrDup(buf);
  1188. X            }
  1189. X            else {        /* all done */
  1190. X            PLFreeMem(Sp0);
  1191. X            Sp0 = NULL;
  1192. X            }
  1193. X            }
  1194. X        /* patch return stack by looking for prev BEOL or HEOL */
  1195. X        /* This is what actually causes the iteration */
  1196. X        while (macroflag[Sretoffs -= 1] != 2)
  1197. X            ;
  1198. X        Sretoffs += 1;
  1199. X        /* after patching my ret addr, add new stack frame */
  1200. X        AddLineToStack(consline);
  1201. X        }
  1202. X        break;
  1203. X        }
  1204. X
  1205. X    case 9: {
  1206. X        Message("NYET");
  1207. X        TraceBack();
  1208. X        break;
  1209. X        }
  1210. X
  1211. X    }
  1212. X
  1213. X    consline[conslinesize = 0] = 0; /* clear constructed line */
  1214. X    if (macroflag[Sretoffs] == 2)   /* skip trailing BEOL if there */
  1215. X    Sretoffs += 1;
  1216. X
  1217. X    /* handle skips locally if possible */
  1218. X    if (skipping < 0) {
  1219. X    /* negative skips discard traceback stack entries */
  1220. X    while (skipping < 0 && 0 < tstacksize) {
  1221. X        PopTStack();
  1222. X        skipping += 1;
  1223. X        }
  1224. X    skipping = 0;
  1225. X    }
  1226. X    else if (0 < skipping) {
  1227. X    /* positive skips skip lines */
  1228. X    while (0 < skipping && 0 < tstacksize) {
  1229. X        while (2 != macroflag[Sretoffs] && 3 != macroflag[Sretoffs])
  1230. X        Sretoffs += 1;
  1231. X        if (3 == macroflag[Sretoffs]) {
  1232. X        PopTStack();    /* reached end of macro body */
  1233. X        }
  1234. X        else {
  1235. X        skipping -= 1;    /* reached end of line */
  1236. X        Sretoffs += 1;    /* skip BEOL marker */
  1237. X        }
  1238. X        }
  1239. X    /* here, if lines remain, ParseFile will skip them. */
  1240. X    }
  1241. X
  1242. X    }
  1243. X
  1244. X
  1245. END_OF_FILE
  1246. if test 6778 -ne `wc -c <'LOME/LOME5.c'`; then
  1247.     echo shar: \"'LOME/LOME5.c'\" unpacked with wrong size!
  1248. fi
  1249. # end of 'LOME/LOME5.c'
  1250. fi
  1251. if test -f 'LOME/SCMdebug.mac' -a "${1}" != "-c" ; then 
  1252.   echo shar: Will not clobber existing file \"'LOME/SCMdebug.mac'\"
  1253. else
  1254. echo shar: Extracting \"'LOME/SCMdebug.mac'\" \(7108 characters\)
  1255. sed "s/^X//" >'LOME/SCMdebug.mac' <<'END_OF_FILE'
  1256. XFILE: SCMdebug.mac
  1257. XThis file contains the macro definitions for SCM, the Simple Character
  1258. XManipulation language. This file must be changed from implementation to
  1259. Ximplementation. This file can serve as the first argument to Comp1.
  1260. XThis particular version is for generating C source code where longs
  1261. Xare 32 bits, shorts are more than 8 bits, and the MacroIO package in C
  1262. Xis available. This version generates inline DEBUGF statements.
  1263. X
  1264. X0$.$>
  1265. XBEGIN PROGRAM.
  1266. X/*
  1267. X * SCM Executable program.
  1268. X * Generated by SCM Macros.
  1269. X *
  1270. X */
  1271. X#include "PPL.h"
  1272. X#include "MacroIO.h"
  1273. X                        /* */
  1274. X/* Declare the memory cells */
  1275. X#define MEMSIZ 6000
  1276. Xlong MEM[MEMSIZ];
  1277. X                        /* */
  1278. X/* Declare the registers */
  1279. Xshort FA, FB, FC, FD, FE, FF, FG, FH, FI, FJ, FK, FL, FM;
  1280. Xshort FN, FO, FP, FQ, FR, FS, FT, FU, FV, FW, FX, FY, FZ;
  1281. Xshort F0, F1, F2, F3;
  1282. Xshort VA, VB, VC, VD, VE, VF, VG, VH, VI, VJ, VK, VL, VM;
  1283. Xshort VN, VO, VP, VQ, VR, VS, VT, VU, VV, VW, VX, VY, VZ;
  1284. Xshort V0, V1, V2, V3, V4, V5, V6, V7, V8, V9;
  1285. Xlong  PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PL, PM;
  1286. Xlong  PN, PO, PP, PQ, PR, PS, PT, PU, PV, PW, PX, PY, PZ;
  1287. Xlong  P0, P1, P2, P3, P4, P5, P6, P7, P8, P9;
  1288. X                        /* */
  1289. Xvoid Stop ARGS((short, short, long));
  1290. Xvoid Oops ARGS((char *));
  1291. X                        /* */
  1292. Xvoid Stop ARGS3(short,flg,short,val,long,ptr)
  1293. X{
  1294. X    DEBUGF(7, "flg=%d, val=%d, ptr=%d=%080x, MEM=%08x" C flg C val
  1295. X    C ptr C ptr C MEM);    /* DEBUGF continued */
  1296. X    DEBUG_EXIT();
  1297. X    PLStatus(1, "Stop!");
  1298. X    PLExit(PLsev_error);
  1299. X    }
  1300. X                        /* */
  1301. Xvoid Oops ARGS1(char*,s)
  1302. X{
  1303. X    PLStatus(1, "Oops:");
  1304. X    PLStatus(1, s);
  1305. X    DEBUG_EXIT();
  1306. X    PLExit(PLsev_error);
  1307. X    }
  1308. X                        /* */
  1309. X/* BEGIN PROGRAM. */
  1310. X                        /* */
  1311. X>
  1312. XEND PROGRAM.
  1313. X/* END PROGRAM. */
  1314. X/* End of generated file */
  1315. X>
  1316. XBEGIN MAIN ROUTINE.
  1317. X/* BEGIN MAIN ROUTINE. */
  1318. Xshort DoIt()
  1319. X{
  1320. X    DEBUG_ENTER("MAIN ROUTINE", NULL);
  1321. X    F0 = 0; F1 = 1; F2 = 2; F3 = 3;
  1322. X    V0 = 0; V1 = 1; V2 = 2; V3 = 3; V4 = 4;
  1323. X    V5 = 5; V6 = 6; V7 = 7; V8 = 8; V9 = 9;
  1324. X    P0 = 0; P1 = 1; P2 = 2; P3 = 3; P4 = 4;
  1325. X    P5 = 5; P6 = 10;
  1326. X    P8 = ((long) MEM);
  1327. X    P9 = ((long) MEM) + sizeof(long) * MEMSIZ;
  1328. X    DEBUGF(5, "P8=%08x, P9=%08x" C P8 C P9);
  1329. X    MStartIO(PLargcnt, PLarglist);
  1330. X>
  1331. XEND MAIN ROUTINE.
  1332. X/* END MAIN ROUTINE. */
  1333. X    DEBUG_RETURN(NULL);
  1334. X    MStopIO();
  1335. X    return 0;
  1336. X    }
  1337. X>
  1338. XBEGIN SUBROUTINE $.
  1339. X/* BEGIN SUBROUTINE $10. */
  1340. Xvoid Sub$10(void);
  1341. Xvoid Sub$10()
  1342. X{
  1343. X    DEBUG_ENTER("Sub$10", NULL);
  1344. X>
  1345. XEND SUBROUTINE $.
  1346. X/* END SUBROUTINE $10. */
  1347. X    DEBUG_RETURN(NULL);
  1348. X    return;
  1349. X    }
  1350. X>
  1351. XLABEL $$.
  1352. X    LABEL$10$20:
  1353. XDEBUGF(5, "LABEL $10$20");
  1354. X>
  1355. XCHRDATA $$ $ $ $$.
  1356. X    {unsigned f = $30, v = '$40', p = $50*10+$60;
  1357. X    MEM[$10*10+$20] = (v << 24) | ((f & 3) << 22) | (p & 0x3FFFFF);}
  1358. X>
  1359. XNUMDATA $$ $ $$ $$.
  1360. X    {unsigned f = $30, v = $40*10+$50, p = $60*10+$70;
  1361. X    MEM[$10*10+$20] = (v << 24) | ((f & 3) << 22) | (p & 0x3FFFFF);}
  1362. X>
  1363. XSTOP $.
  1364. XDEBUGF(5, "STOP $10");
  1365. X    Stop(F$10, V$10, P$10);
  1366. X>
  1367. XCALL $.
  1368. XDEBUGF(5, "CALL $10");
  1369. X    Sub$10();
  1370. X>
  1371. XGET $ = MEM $.
  1372. XDEBUGF(7, "GET $10 = MEM $20");
  1373. X    if (P$20 < MEM || MEM + MEMSIZ <= P$20 || 0 != (P$20 & 3))
  1374. X    Oops("Get $00 out of range: P$20");
  1375. X    {long temp;
  1376. X    temp = * (long *) P$20;
  1377. X    V$10 = (temp >> 24) & 0xFF;
  1378. X    F$10 = (temp >> 22) & 0x03;
  1379. X    P$10 = (temp << 10) >> 10;  /* do sign extend */
  1380. XDEBUGF(8, "     Now, F$10=%d, V$10=%d, P$10=%d" C F$10 C V$10 C P$10);
  1381. X    }
  1382. X>
  1383. XPUT MEM $ = $.
  1384. XDEBUGF(7, "PUT MEM $10 = $20");
  1385. X    if (P$10 < MEM || MEM + MEMSIZ <= P$10 || 0 != (P$20 & 3))
  1386. X    Oops("Put $00 out of range: P$10");
  1387. X    {long temp;
  1388. X    temp = (V$20 << 24) | ((F$20 & 3) << 22) | (P$20 & 0x3FFFFF);
  1389. X    * (long *) P$10 = temp;
  1390. XDEBUGF(8, "     Put F$20=%d, V$20=%d, P$20=%d" C F$20 C V$20 C P$20);
  1391. X    }
  1392. X>
  1393. XFLG $ = $.
  1394. XDEBUGF(7, "FLG $10 = $20");
  1395. X    F$10 = F$20;
  1396. XDEBUGF(8, "     Now, F$10=%d" C F$10);
  1397. X>
  1398. XPTR $ = VAL $.
  1399. XDEBUGF(7, "PTR $10 = VAL $20");
  1400. X    P$10 = (V$20 & 0xFF);
  1401. XDEBUGF(8, "     Now, P$10=%d" C P$10);
  1402. X>
  1403. XVAL $ = PTR $.
  1404. XDEBUGF(7, "VAL $10 = PTR $20");
  1405. X    V$10 = (P$20 & 0xFF);
  1406. XDEBUGF(8, "     Now, V$10=%d" C V$10);
  1407. X>
  1408. XVAL $ = $ + $.
  1409. XDEBUGF(7, "VAL $10 = $20 + $30");
  1410. X    V$10 = V$20 + V$30;
  1411. XDEBUGF(8, "     Now, V$10=%d" C V$10);
  1412. X>
  1413. XVAL $ = $ - $.
  1414. XDEBUGF(7, "VAL $10 = $20 - $30");
  1415. X    V$10 = V$20 - V$30;
  1416. XDEBUGF(8, "     Now, V$10=%d" C V$10);
  1417. X>
  1418. XPTR $ = $ + $.
  1419. XDEBUGF(7, "PTR $10 = $20 + $30");
  1420. X    P$10 = P$20 + P$30;
  1421. XDEBUGF(8, "     Now, P$10=%d" C P$10);
  1422. X>
  1423. XPTR $ = $ - $.
  1424. XDEBUGF(7, "PTR $10 = $20 - $30");
  1425. X    P$10 = P$20 - P$30;
  1426. XDEBUGF(8, "     Now, P$10=%d" C P$10);
  1427. X>
  1428. XPTR $ = $ * $.
  1429. XDEBUGF(7, "PTR $10 = $20 * $30");
  1430. X    P$10 = P$20 * P$30;
  1431. XDEBUGF(8, "     Now, P$10=%d" C P$10);
  1432. X>
  1433. XPTR $ = $ / $.
  1434. XDEBUGF(7, "PTR $10 = $20 / $30");
  1435. X    P$10 = P$20 / P$30;
  1436. XDEBUGF(8, "     Now, P$10=%d" C P$10);
  1437. X>
  1438. XMOV PTR $ BY $.
  1439. XDEBUGF(7, "MOV PTR $10 BY $20");
  1440. X    P$10 = P$10 + sizeof(long) * P$20;
  1441. XDEBUGF(8, "     Now, P$10=%d=%08x" C P$10 C P$10);
  1442. X>
  1443. XTO $$.
  1444. XDEBUGF(7, "TO $10$20");
  1445. X    goto LABEL$10$20;
  1446. X>
  1447. XTO $$ IF FLG $ EQ $.
  1448. XDEBUGF(7, "TO $10$20 IF FLG $30 EQ $40 (F$30=%d, F$40=%d)" C F$30 C F$40);
  1449. X    if (F$30 == F$40) goto LABEL$10$20;
  1450. X>
  1451. XTO $$ IF FLG $ NE $.
  1452. XDEBUGF(7, "TO $10$20 IF FLG $30 NE $40 (F$30=%d, F$40=%d)" C F$30 C F$40);
  1453. X    if (F$30 != F$40) goto LABEL$10$20;
  1454. X>
  1455. XTO $$ IF VAL $ EQ $.
  1456. XDEBUGF(7, "TO $10$20 IF VAL $30 EQ $40 (V$30=%d, V$40=%d)" C V$30 C V$40);
  1457. X    if (V$30 == V$40) goto LABEL$10$20;
  1458. X>
  1459. XTO $$ IF VAL $ NE $.
  1460. XDEBUGF(7, "TO $10$20 IF VAL $30 NE $40 (V$30=%d, V$40=%d)" C V$30 C V$40);
  1461. X    if (V$30 != V$40) goto LABEL$10$20;
  1462. X>
  1463. XTO $$ IF PTR $ EQ $.
  1464. XDEBUGF(7, "TO $10$20 IF PTR $30 EQ $40 (P$30=%d, P$40=%d)" C P$30 C P$40);
  1465. X    if (P$30 == P$40) goto LABEL$10$20;
  1466. X>
  1467. XTO $$ IF PTR $ NE $.
  1468. XDEBUGF(7, "TO $10$20 IF PTR $30 NE $40 (P$30=%d, P$40=%d)" C P$30 C P$40);
  1469. X    if (P$30 != P$40) goto LABEL$10$20;
  1470. X>
  1471. XTO $$ IF PTR $ LT $.
  1472. XDEBUGF(7, "TO $10$20 IF PTR $30 LT $40 (P$30=%d, P$40=%d)" C P$30 C P$40);
  1473. X    if (P$30 < P$40) goto LABEL$10$20;
  1474. X>
  1475. XREWIND $.
  1476. XDEBUGF(7, "REWIND $10 (V$10=%d)" C V$10);
  1477. X    {long temp;
  1478. X    temp = MRewind(V$10);
  1479. X    if (temp == OK) F$10 = 0; else F$10 = 1;
  1480. XDEBUGF(8, "     Now, F$10=%d" C F$10);
  1481. X    }
  1482. X>
  1483. XGET BUFF $.
  1484. XDEBUGF(7, "GET BUFF $10 (V$10=%d)" C V$10);
  1485. X    F$10 = MGetBuff(V$10);
  1486. XDEBUGF(8, "     Now, F$10=%d" C F$10);
  1487. X>
  1488. XPUT BUFF $.
  1489. XDEBUGF(7, "PUT BUFF $10");
  1490. X    F$10 = MPutBuff(V$10);
  1491. XDEBUGF(8, "     Now, F$10=%d" C F$10);
  1492. X>
  1493. XVAL $ = INPUT.
  1494. XDEBUGF(7, "VAL $10 = INPUT");
  1495. X    V$10 = MGetChar();
  1496. XDEBUGF(8, "     Now, V$10=%d" C V$10);
  1497. X>
  1498. XOUTPUT = VAL $.
  1499. XDEBUGF(7, "OUTPUT = VAL $10");
  1500. X    V$10 = MPutChar(V$10);
  1501. XDEBUGF(8, "     Now, V$10=%d" C V$10);
  1502. X>
  1503. X.   An empty line will match
  1504. X>   An empty line will generate nothing
  1505. XDEBUG.
  1506. X>   The debug statement does nothing yet in compiled code
  1507. XMESSAGE $$$$ TO $.
  1508. XDEBUGF(7, "MESSAGE $10$20$30$40 TO $50");
  1509. X    MPutChar(0);
  1510. X    {long temp;
  1511. X    for (temp = 0; temp < 20; temp++)
  1512. X    MPutChar('*');
  1513. X    MPutChar($10);
  1514. X    MPutChar($20);
  1515. X    MPutChar($30);
  1516. X    MPutChar($40);
  1517. X    MPutChar(' ');
  1518. X    MPutChar('E');
  1519. X    MPutChar('R');
  1520. X    MPutChar('R');
  1521. X    MPutChar('O');
  1522. X    MPutChar('R');
  1523. X    MPutChar('!');
  1524. X    MPutChar(0);
  1525. X    temp = MPutBuff(V$50);
  1526. X    if (temp == OK) F$50 = 0;
  1527. X    else if (temp == EOF) F$50 = 1;
  1528. X    else if (temp == ILLEGAL) F$50 = 2;
  1529. X    }
  1530. X>
  1531. END_OF_FILE
  1532. if test 7108 -ne `wc -c <'LOME/SCMdebug.mac'`; then
  1533.     echo shar: \"'LOME/SCMdebug.mac'\" unpacked with wrong size!
  1534. fi
  1535. # end of 'LOME/SCMdebug.mac'
  1536. fi
  1537. if test -f 'PPL/PPLUnix.c' -a "${1}" != "-c" ; then 
  1538.   echo shar: Will not clobber existing file \"'PPL/PPLUnix.c'\"
  1539. else
  1540. echo shar: Extracting \"'PPL/PPLUnix.c'\" \(6076 characters\)
  1541. sed "s/^X//" >'PPL/PPLUnix.c' <<'END_OF_FILE'
  1542. X/*
  1543. X * PPLUnix.c
  1544. X * Portable Programmer's Library General Host Code
  1545. X * Unix version
  1546. X * Copyright 1988, 1990 Darren New.  All Rights Reserved.
  1547. X *
  1548. X * Started 19-Feb-88 DHN
  1549. X * LastMod 07-jul-90 DHN
  1550. X *
  1551. X */
  1552. X
  1553. X#include "PPL.h"
  1554. X
  1555. X
  1556. X#define MAXARGC 20    /* max # args we are willing to remember */
  1557. X
  1558. X
  1559. XHIDDEN long memcount;
  1560. X
  1561. X
  1562. Xvoid PLExit(short severity)
  1563. X{
  1564. X    exit((int) severity);
  1565. X    }
  1566. X
  1567. Xptr PLAllocMem(size, flags)
  1568. X    long size;
  1569. X    int flags;
  1570. X{
  1571. X
  1572. X#ifdef CHECKALLOC
  1573. X
  1574. X    /* Note that this has some debugging stuff in it */
  1575. X        /**** OLD -- MUST BE CHECKED!! ****/
  1576. X    ptr retval;
  1577. X    inx i;
  1578. X    assert(size < BIGMEM);
  1579. X    retval = (ptr) malloc(size + sizeof(long) + sizeof(long) + (size & 1));
  1580. X    if (retval == NULL) {
  1581. X    if (flags & PLalloc_die) {
  1582. X        bomb("Out of Memory");
  1583. X        PLExit(PLsev_oores);
  1584. X        }
  1585. X    else
  1586. X        return retval;
  1587. X    }
  1588. X    else {
  1589. X    if (flags & PLalloc_zero)
  1590. X        for (i = size + 2 * sizeof(long) + (size & 1) - 1; 0 <= i; i--)
  1591. X        retval[i] = '\0';
  1592. X    memcount += 1;
  1593. X    (* (long *) retval) = 0xA5A55A5A;
  1594. X    (* (long *) (retval + sizeof(long) + size + (size & 1))) = 0x5A5AA5A5;
  1595. X    return retval + sizeof(long);
  1596. X    }
  1597. X
  1598. X#else
  1599. X
  1600. X    char * retval;
  1601. X    inx i;
  1602. X    assert(size < BIGMEM);
  1603. X    assert(size < 65530L);
  1604. X    assert(0 < size);
  1605. X    retval = malloc((unsigned) size);
  1606. X    if (retval == NULL) {
  1607. X    if (flags & PLalloc_die) {
  1608. X        bomb("Out of Memory");
  1609. X        PLExit(PLsev_oores);
  1610. X        return NULL;    /* to shut up compiler */
  1611. X        }
  1612. X    else {
  1613. X        return NULL;
  1614. X        }
  1615. X    }
  1616. X    else {
  1617. X    if (flags & PLalloc_zero) {
  1618. X        for (i = 0; i < size; i++) {
  1619. X        retval[i] = '\0';
  1620. X        }
  1621. X        }
  1622. X    memcount += 1;
  1623. X    return (ptr) retval;
  1624. X    }
  1625. X
  1626. X#endif
  1627. X
  1628. X    }
  1629. X
  1630. X
  1631. Xvoid PLFreeMem(where)
  1632. X    ptr where;
  1633. X{
  1634. X
  1635. X#ifdef CHECKALLOC
  1636. X
  1637. X    /* note that this has some debugging stuff in it */
  1638. X    assert(where != NULL);
  1639. X    where -= sizeof(long);
  1640. X    if (* (long *) where == 0x19919119)
  1641. X    bomb("Freed memory twice!");
  1642. X    if (* (long *) where != 0xA5A55A5A)
  1643. X    bomb("Freed non-malloced memory!");
  1644. X    (* (long *) where) = 0x19919119;
  1645. X    free(where);
  1646. X    memcount -= 1;
  1647. X
  1648. X#else
  1649. X
  1650. X    extern void free(void *);
  1651. X    assert(where != NULL);
  1652. X    free(where);
  1653. X    memcount -= 1;
  1654. X
  1655. X#endif
  1656. X
  1657. X    }
  1658. X
  1659. Xstr PLStrDup(s)
  1660. X    str s;
  1661. X{
  1662. X    str t;
  1663. X    t = PLAllocMem(strlen(s)+1, PLalloc_die);
  1664. X    strcpy((char *) t, (char *) s);
  1665. X    return t;
  1666. X    }
  1667. X
  1668. Xvoid PLCopyMem(to, from, siz)
  1669. X    ptr to;
  1670. X    ptr from;
  1671. X    long siz;
  1672. X{
  1673. X    /* be lazy and use lattice function here */
  1674. X    extern void *memcpy(void *, void *, unsigned);
  1675. X    assert(0 < siz);
  1676. X    assert(siz < BIGMEM);
  1677. X    assert(NULL != to);
  1678. X    assert(NULL != from);
  1679. X    (void) memcpy((char *) to, (char *) from, (unsigned) siz);
  1680. X    }
  1681. X
  1682. Xvoid PLFillMem(ptr where, long siz, char chr)
  1683. X{
  1684. X    char * whr = where;
  1685. X    assert(whr != NULL);
  1686. X    assert(0 < siz);
  1687. X    assert(siz < 32760);
  1688. X    assert(siz < BIGMEM);
  1689. X
  1690. X    /* setmem((char *) where, (unsigned) siz, chr); */
  1691. X
  1692. X    /* I don't trust Lattice at this point... */
  1693. X    while (0 < siz--)
  1694. X    *whr++ = chr;
  1695. X    }
  1696. X
  1697. Xptr PLFindMem(ptr where, long siz, char chr)
  1698. X{
  1699. X    extern void *memchr(void *, int, unsigned);
  1700. X    assert(where != NULL);
  1701. X    assert(0 < siz);
  1702. X    assert(siz < BIGMEM);
  1703. X    return (ptr) memchr((char *) where, chr, (unsigned) siz);
  1704. X    }
  1705. X
  1706. X
  1707. X/* The error strings: */
  1708. XHIDDEN str PLerrstrs[] = {
  1709. X    /* 0*/  "No Error",
  1710. X    /* 1*/  "DOS error (retryable)",
  1711. X    /* 2*/  "DOS error (wait/retry)",
  1712. X    /* 3*/  "DOS error (please fix)",
  1713. X    /* 4*/  "DOS error (failure)",
  1714. X    /* 5*/  "Program fault",
  1715. X    /* 6*/  "End of data during input",
  1716. X    /* 7*/  "Out of resource during output",
  1717. X    /* 8*/  "Multiple errors occured without being cleared",
  1718. X    /* 9*/  "Item does not exist",
  1719. X    /*10*/  "Item already exists",
  1720. X    /*11*/  "You are not allowed to do that",
  1721. X    /*12*/  "That opperation is not supported here",
  1722. X    /*13*/  "Item is busy",
  1723. X    /*14*/  "Item name missing or incorrectly formed",
  1724. X    /*15*/  "Not Yet Implemented",
  1725. X    /*16*/  "Cannot be Implemented",
  1726. X    /*17*/  "Argument to internal function semantically invalid",
  1727. X    /*18*/  "Overflow error",
  1728. X    /*19*/  "Underflow error",
  1729. X    /*20*/  "User break or interrupted system call",
  1730. X    /*21*/  "Error number out of range",
  1731. X    NULL
  1732. X    };
  1733. X
  1734. XPLerr_enum PLerr;
  1735. X
  1736. Xint OSerr;
  1737. X
  1738. X/* The file and line of the last error (mainly for debugging) */
  1739. Xstr PLerr_file;
  1740. Xlong PLerr_line;
  1741. X
  1742. Xstr PLErrText()
  1743. X{
  1744. X    if ( PLerr < 0 || PLerr_last < PLerr )
  1745. X    PLerr = PLerr_last;
  1746. X    return PLerrstrs[PLerr];
  1747. X    }
  1748. X
  1749. Xstr PLOSErrText()
  1750. X{
  1751. X    extern char * sys_errlist[];
  1752. X    extern int sys_nerr;
  1753. X
  1754. X    if (OSerr < 0 || sys_nerr <= OSerr)
  1755. X    return "PSoserrtext bad OSerr number";
  1756. X    else
  1757. X    return sys_errlist[OSerr];
  1758. X    }
  1759. X
  1760. Xshort PLstatuslevel = 6;
  1761. X
  1762. Xvoid PLStatus(short level, str message)
  1763. X{
  1764. X    if (PLstatuslevel < level)
  1765. X    return;
  1766. X    if (PLcmdname && *PLcmdname) {
  1767. X    fprintf(stderr, "%s: ", PLcmdname);
  1768. X    }
  1769. X    fprintf(stderr, "%s\n", message);
  1770. X    fflush(stderr);
  1771. X    }
  1772. X
  1773. Xvoid PLDelay(short secs)
  1774. X{
  1775. X    assert(0 <= secs);
  1776. X    if (secs != 0)
  1777. X    (void) sleep((unsigned) secs);
  1778. X    }
  1779. X
  1780. Xvoid PLBeep(short how)
  1781. X{
  1782. X    fprintf(stderr, "\a");
  1783. X    }
  1784. X
  1785. X
  1786. X/* This gives the name of the command, if available.
  1787. X */
  1788. Xstr PLcmdname;
  1789. X
  1790. X/* This gives the host-syntax filename for the executable file,
  1791. X * if available.
  1792. X */
  1793. Xstr PLcmdfile;
  1794. X
  1795. X/* This tells how many command-line arguments there were, excluding
  1796. X * the command name.
  1797. X */
  1798. Xshort PLargcnt;
  1799. X
  1800. X/* This is the array of command-line argument strings.
  1801. X */
  1802. Xstr PLarglist[MAXARGC];
  1803. X
  1804. X/* These are the flags describing the command-line parameters.
  1805. X */
  1806. Xlong PLargflags;
  1807. X
  1808. X/* Here is the main() that sets all this up, calls DoIt() and exits.
  1809. X */
  1810. X
  1811. X#if HIDPROTS
  1812. Xvoid main ARGS((int argc, char * argv[]));
  1813. X#endif
  1814. X
  1815. Xvoid main(int argc, char * argv[])
  1816. X{
  1817. X
  1818. X    /* Eventually, we will want to init PLstatuslevel from an env var
  1819. X       or something similar. */
  1820. X
  1821. X    if (0 < argc) {
  1822. X    char * cp;
  1823. X    inx i;
  1824. X    cp = argv[0] + strlen(argv[0]) - 1;
  1825. X    while (argv[0] < cp && *cp != '/' && *cp != ':')
  1826. X        cp -= 1;
  1827. X    PLcmdname = cp;
  1828. X    PLargcnt = argc - 1;
  1829. X    for (i = 1; i < argc && i < MAXARGC; i++)
  1830. X        PLarglist[i-1] = argv[i];
  1831. X    }
  1832. X    PLcmdname = argv[0];
  1833. X    PLExit(DoIt());
  1834. X    }
  1835. X
  1836. X
  1837. X/************* END OF FILE ***************/
  1838. X
  1839. END_OF_FILE
  1840. if test 6076 -ne `wc -c <'PPL/PPLUnix.c'`; then
  1841.     echo shar: \"'PPL/PPLUnix.c'\" unpacked with wrong size!
  1842. fi
  1843. # end of 'PPL/PPLUnix.c'
  1844. fi
  1845. if test -f 'TFS/TFS.h' -a "${1}" != "-c" ; then 
  1846.   echo shar: Will not clobber existing file \"'TFS/TFS.h'\"
  1847. else
  1848. echo shar: Extracting \"'TFS/TFS.h'\" \(6101 characters\)
  1849. sed "s/^X//" >'TFS/TFS.h' <<'END_OF_FILE'
  1850. X/*
  1851. X * TFS.h
  1852. X * Portable Programmer's Library Text File Subsystem Header File
  1853. X * Copyright 1988 Darren New.  All Rights Reserved.
  1854. X *
  1855. X * Started: 26-Feb-88 DHN
  1856. X * LastMod: 05-jan-90 DHN
  1857. X *
  1858. X */
  1859. X
  1860. X#ifndef TFS_h
  1861. X#define TFS_h
  1862. X
  1863. Xtypedef long TFSfile;    /* a handle to a file */
  1864. Xtypedef long TFSnote;    /* file position information */
  1865. X
  1866. X
  1867. X/*
  1868. X * This initialized anything the TFS might need. Do not call this
  1869. X * twice in a row. If this detects an error, it will bomb().
  1870. X */
  1871. Xextern void TFSInit ARGS((void));
  1872. X
  1873. X/*
  1874. X * This returns TRUE if TFS has been initialized, FALSE if not.
  1875. X */
  1876. Xextern bool TFSHasBeenInit ARGS((void));
  1877. X
  1878. X/*
  1879. X * This allows a gracefull cleanup of anything TFSInit() may have
  1880. X * done. It is not guaranteed to close all TFS files, but it might.
  1881. X */
  1882. Xextern void TFSTerm ARGS((void));
  1883. X
  1884. X
  1885. X/* This opens a text file. It returns a zero on failure, with the
  1886. X * appropriate PLerr set. It returns non-zero on success, and expects
  1887. X * the returned value to be passed to all the other routines below.
  1888. X * The FNAME parameter is the textual representation of the file name
  1889. X * as the user selected it. Note that this is allowed to have strange
  1890. X * stuff in it, as long as these routines know what is going on.
  1891. X * The FNAME is expected to be a NUL-teminated string, as is the MODE.
  1892. X * The following characters are legal in the MODE string:
  1893. X * L - Locate (return TFSfile or error without actually opening)
  1894. X * C - Create (if file did not exist, create it; if it did, ignore this)
  1895. X * T - Truncate (if file did exist, truncate it; if not, ignore this)
  1896. X * A - Append (if file did exist, append to it; if not, ignore this)
  1897. X * R - Read (file is allowed to be read)
  1898. X * W - Write (file is allowed to be written)
  1899. X * P - Position (file is allowed to be positioned (TFSNote and TFSPoint))
  1900. X * D - Destroy (file is allowed to be destroyed instead of closed)
  1901. X *
  1902. X * L may be combined with any other command. The file will be checked
  1903. X * for the proper permissions, but will not be opened.
  1904. X * P is applicable only with R, and if absent may cause TFSInfo() to
  1905. X * return less information than if present. If P is present and the
  1906. X * file is on a non-"seekable" device (e.g., a terminal), an error may
  1907. X * be returned then or at the time of the position.
  1908. X * T and A are mutually exclusive, and if W is present one of T or A must
  1909. X * also be present; T and A are not allowed without W.
  1910. X * R and W are mutually exclusive.
  1911. X * Note that C and A are not exclusive; neither are C and D, or C and T,
  1912. X * or C and R (which makes an empty file open for reading if it is not
  1913. X * already existant).
  1914. X */
  1915. Xextern TFSfile TFSOpen ARGS((str fname, str mode));
  1916. X
  1917. X/* This closes a text file. It returns a FALSE on failure, with the
  1918. X * appropriate PLerr set; it returns TRUE on success.
  1919. X * It is a "bombable" error to pass an unopen file (or invalid handle)
  1920. X * to this routine.
  1921. X * It does not destroy the data in the file, even if "D" was
  1922. X * specified during TFSOpen(). It merely disconnects
  1923. X * the file and allows others to use it. It deallocates any buffers
  1924. X * obtained from TFSOpen() and so on.
  1925. X */
  1926. Xextern bool TFSClose ARGS((TFSfile handle));
  1927. X
  1928. X/* This destroys a text file. It returns a FALSE on failure, with the
  1929. X * appropriate PLerr set; it returns TRUE on success. The file
  1930. X * must have been previously opened by TFSOpen() with "D" in the mode.
  1931. X * It is a "bombable" error to pass an invalid or unopen handle to this.
  1932. X * No other permissions are required in the mode, but they may be
  1933. X * required by the host operating system.
  1934. X * The handle is invalid (closed) after a call to this routine, even if
  1935. X * the routine returned an error.
  1936. X */
  1937. Xextern bool TFSDestroy ARGS((TFSfile handle));
  1938. X
  1939. X/*  @$@$
  1940. XTFSInfo()       - Determine file parameters. This may return various
  1941. Xparameters about the given file. The description of the information
  1942. Xreturned is given in the TFS.h file.
  1943. X*/
  1944. X
  1945. X/* Read a line. Only entire lines are read. A '\0' is appened to
  1946. X * the buffer. Lines longer than BIGLINE - 1 get truncated with an
  1947. X * error return. The return is the number of characters read excluding
  1948. X * the NUL appended by the read. The record separator is never returned.
  1949. X * End-of-file is indicated by a return of -1 with PLerr set to PLerr_eod.
  1950. X * All errors return with a zero-length string in buf.
  1951. X * It is a "bombable" error to pass an unopen or invalid handle to this.
  1952. X * All other errors are also indicated by a return of -1 with the error
  1953. X * code in PLerr. NOTE: Trailing whitespace (a la isspace()) is
  1954. X * eliminated from the buffer before returning. The line, INCLUDING
  1955. X * TRAILING WHITESPACE, must have a length of less than BIGLINE - 1.
  1956. X * The returned buffer is guaranteed to meet strlen(buf) < BIGLINE.
  1957. X */
  1958. Xextern short TFSRead ARGS((TFSfile handle, str buf));
  1959. X
  1960. X/* Write a line. Only entire lines are written. BUF must be NUL terminated.
  1961. X * The return is TRUE for a successful write or FALSE with PLerr set if
  1962. X * an error occured. The BUF must have strlen < BIGLINE - 1.
  1963. X * Trailing whitespace (a la isspace()) in the buffer will be discarded
  1964. X * on output without change to the buffer.
  1965. X * It is a "bombable" error to pass an unopen or invalid handle to this.
  1966. X */
  1967. Xextern bool TFSWrite ARGS((TFSfile handle, str buf));
  1968. X
  1969. X/* Remember where the file is positioned. This returns a long value that
  1970. X * can be passed to TFSPoint() to reposition the file in such a way that
  1971. X * the same line will be read after TFSNote() and TFSPoint(). Note that
  1972. X * this value is valid for this TFSOpen() only; i.e., this can NOT be
  1973. X * saved when the file is closed, and it can NOT be applied to a
  1974. X * different file.
  1975. X * It is a "bombable" error to pass an unopen or invalid handle to this.
  1976. X * The format of the TFSnote returned is a long, but the only values
  1977. X * usable by the application are zero and non-zero; a return of zero
  1978. X * indicates an error occured, and a return of non-zero indicates
  1979. X * success.
  1980. X */
  1981. Xextern long TFSNote ARGS((TFSfile handle));
  1982. X
  1983. X/* Reposition a file -- see TFSNote().  Returns TRUE for success, FALSE
  1984. X * for error.
  1985. X * It is a "bombable" error to pass an unopen or invalid handle to this.
  1986. X */
  1987. Xextern bool TFSPoint ARGS((TFSfile handle, TFSnote pos));
  1988. X
  1989. X
  1990. X#endif /* TFS_h */
  1991. X
  1992. END_OF_FILE
  1993. if test 6101 -ne `wc -c <'TFS/TFS.h'`; then
  1994.     echo shar: \"'TFS/TFS.h'\" unpacked with wrong size!
  1995. fi
  1996. # end of 'TFS/TFS.h'
  1997. fi
  1998. echo shar: End of archive 4 \(of 9\).
  1999. cp /dev/null ark4isdone
  2000. MISSING=""
  2001. for I in 1 2 3 4 5 6 7 8 9 ; do
  2002.     if test ! -f ark${I}isdone ; then
  2003.     MISSING="${MISSING} ${I}"
  2004.     fi
  2005. done
  2006. if test "${MISSING}" = "" ; then
  2007.     echo You have unpacked all 9 archives.
  2008.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2009. else
  2010.     echo You still need to unpack the following archives:
  2011.     echo "        " ${MISSING}
  2012. fi
  2013. ##  End of shell archive.
  2014. exit 0
  2015. -- 
  2016. --- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
  2017.  
  2018. exit 0 # Just in case...
  2019. -- 
  2020. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  2021. Use a domain-based address or give alternate paths, or you may lose out.
  2022.